package com.szbmyoubao.app.http

import com.ellecity06.common.http.entity.ApiResponse
import com.szbmyoubao.app.bean.request.ForgetPwdRequest
import com.szbmyoubao.app.bean.request.LoginRequest
import com.szbmyoubao.app.bean.request.RegisterRequest
import com.szbmyoubao.app.bean.request.SendSmsCodeRequest
import com.szbmyoubao.app.bean.request.VersionInfoRequest
import com.szbmyoubao.app.bean.response.AppVersionResponse
import com.szbmyoubao.app.bean.response.MemberInfo
import com.szbmyoubao.app.bean.response.UploadFileResponse
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Streaming
import retrofit2.http.Url


/**
 * @author ellecity06
 * @time 2023/4/13 12:02
 * @des
 */
interface ApiService {

    @Streaming
    @GET
    suspend fun download(@Url url: String): Response<ResponseBody>

    @POST("api/file/uploadV2")
    suspend fun uploadFiles(@Body requestBody: RequestBody): ApiResponse<UploadFileResponse>

    /**
     * 查询最新版本信息
     */
    @POST("api/web/setting/getLastVersionInfo")
    suspend fun lastVersion(@Body request: VersionInfoRequest): ApiResponse<AppVersionResponse>

    /**
     * 用户注销
     */
    @POST("api/web/auth/cancelMember")
    suspend fun cancelMember(): ApiResponse<String>

    /**
     * 注册
     */
    @POST("api/web/auth/register")
    suspend fun register(@Body request: RegisterRequest): ApiResponse<String>

    /**
     * 密码登录
     */
    @POST("api/user/login")
    suspend fun login(@Body request: LoginRequest): ApiResponse<MemberInfo>

    /**
     * 验证码登录
     */
    @POST("api/web/auth/smsLogin")
    suspend fun smsCodeLogin(@Body request: LoginRequest): ApiResponse<MemberInfo>

    /**
     * 退出登录
     */
    @POST("api/web/auth/logout")
    suspend fun logout(): ApiResponse<String>

    @POST("api/web/auth/updateMemberPwd")
    suspend fun forgetPwd(@Body request: ForgetPwdRequest): ApiResponse<String>

    /**
     * 获取短信验证码
     */
    @POST("api/sms/send")
    suspend fun smsCode(@Body request: SendSmsCodeRequest): ApiResponse<String>


//    用户相关 ======
    /**
     * 获取用户信息
     */
    @POST("api/user/info")
    suspend fun userInfo(): ApiResponse<MemberInfo?>


}